<?php
namespace App\Http\Controllers\Admin;

use App\Models\Announce;
use Illuminate\Support\Facades\Redirect;

class AnnounceController extends BaseController
{

    public function __construct(Announce $announce)
    {
        parent::__construct();
        $this->announce = $announce;
    }


    //总后台公告
    public function getIndex()
    {
        $flag = 'announce';
        $res = $this->announce->getAnnounceList(request());
        //dd($res);
        return view('admin.notic.index',compact('res','flag'));

    }


    public function postAdd()
    {
        $res = $this->announce->addAnnounce(request());

        //return view('admin.notic.index');
        // return ajax_return($res);
        return Redirect::to('center/announce');

    }

    public function postEdit()
    {
        $res = $this->announce->editAnnounce(request());
        return ajax_return($res);
    }

    public function postChangeStatus()
    {
        $res = $this->announce->changeStatus(request());
        return ajax_return($res);
    }


    //ajax删除公告
    public function postZongAnnounceDel()
    {
        $res = $this->announce->delAnnounceDelById(request());
        return ajax_return($res);
    }

}